﻿using System.Drawing;
using System.Windows.Forms;

namespace Quakk.Controls
{
    public class MenuButton : Panel 
    {
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics gfx = e.Graphics;

            Brush backgroundBrush = Display.StandardTweetBrush;
            Pen borderPen = Display.BorderPen;
            Brush textBrush = Display.TitleBrush;
            Font font = Display.TitleFont;
            SizeF textSize = gfx.MeasureString(Text, font);
            RectangleF textRect = new RectangleF((Width - textSize.Width) / 2, (Height - textSize.Height) / 2, textSize.Width, textSize.Height);

            gfx.FillRectangle(backgroundBrush, 0, 0, Width, Height);
            gfx.DrawRectangle(borderPen, 0, 0, Width - 1, Height - 1);
            gfx.DrawString(Text, font, textBrush, textRect);

            font.Dispose();
            textBrush.Dispose();
            borderPen.Dispose();
            backgroundBrush.Dispose();
        }
    }
}
